module Reverser (
	
	input [7:0] RevIn,	//The 8-bit BCD value input. Tips that is two 4-bit BCDs
	input ModeSel,			//Control signal to make the counting upwards RevIn to Counting downwards RevOut (HIGH) or pass the RevIn to the RevOut (LOW).
	
	output [7:0] RevOut	//the 8-bit BCD value out
	
);

	wire [3:0] nine = 4'd9;
	wire [3:0] sub_low;
	wire [3:0] sub_high;

	wire dummy_Cout;

	FourBitFullAdder subL (
		.A    (nine),
		.B    (~RevIn[3:0]),
		.Cin  (1'b1),
		.Sum  (sub_low),
		.Cout (dummy_Cout)
	);

	FourBitFullAdder subH (
		.A    (nine),
		.B    (~RevIn[7:4]),
		.Cin  (1'b1),
		.Sum  (sub_high),
		.Cout (dummy_Cout)
	);

	Mux2To1_4 muxL (
		.sel  (ModeSel),
		.a    (RevIn[3:0]),
		.b    (sub_low),
		.out  (RevOut[3:0])
	);

	Mux2To1_4 muxH (
		.sel  (ModeSel),
		.a    (RevIn[7:4]),
		.b    (sub_high),
		.out  (RevOut[7:4])
	);

endmodule
